package logic

import (
	"context"
	"srv/srv"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseCoverLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHouseCoverLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseCoverLogic {
	return &HouseCoverLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HouseCoverLogic) HouseCover(req *types.HouseCoverRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	house, err := l.svcCtx.Srv.HouseCover(l.ctx, &srv.HouseCoverRequest{
		HouseId: req.HouseId,
		Living:  req.Living,
		Sleep:   req.Sleep,
		Kitchen: req.Kitchen,
		Toilet:  req.Toilet,
	})

	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  err.Error(),
			Data: nil,
		}, nil

	}

	return &types.Response{
		Code: 200,
		Msg:  "房源图片添加成功",
		Data: map[string]interface{}{
			"house": house,
		},
	}, nil
}
